#!/bin/bash

# rm -rf ./tmp
# mkdir ./tmp/
# nasm -f elf32 ./kernel.asm -o ./tmp/kernel.o
# nasm -f elf32 ./liba.asm -o ./tmp/liba.o
# gcc -c -nostdlib -l ./string.h ./libc.c -o ./tmp/libc.o
# #gcc -c -m16 -march=i386 -masm=intel -nostdlib -ffreestanding -mpreferred-stack-boundary=2 -lgcc -shared ./libc.c -o ./tmp/libc.o

# #ld -m elf_i386 -N -Ttext 0x8000 --oformat binary ./tmp/kernel.o ./tmp/liba.o ./tmp/libc.o -o ./tmp/kernel.bin 
# ld -m elf_i386 -Ttext 0x8000 ./tmp/kernel.o ./tmp/liba.o ./tmp/libc.o -o ./tmp/kernel.elf 
# echo "Done!"



rm -rf ./tmp
mkdir ./tmp/
nasm ./mbr.asm -o ./tmp/mbr.bin
nasm ./loader.asm -o ./tmp/loader.bin
nasm -f elf32 ./kernel.asm -o ./tmp/kernel.o
nasm -f elf32 ./liba.asm -o ./tmp/liba.o
gcc -m16  -march=i386 -ffreestanding -c ./string.h -o ./tmp/string.o
gcc -m16  -march=i386 -ffreestanding -c -nostdlib -l ./string.h ./libc.c -o ./tmp/libc.o
ld -m elf_i386 -N -Ttext 0x00 --oformat binary ./tmp/kernel.o ./tmp/liba.o ./tmp/libc.o -o ./tmp/kernel.bin 


# ld -m elf_i386 -Ttext 0x8000 ./tmp/kernel.o ./tmp/liba.o ./tmp/libc.o -o ./tmp/kernel.elf 
# objcopy -O binary ./tmp/kernel.elf ./tmp/kernel.bin
echo "Done!"